extends KinematicBody2D

export var speed = 150.0
export var velocity = Vector2(-1, 0)

var dead = false
var armor_type = 100 # The type of monster

const player_class = preload("res://Scripts/player.gd")

func _fixed_process(delta):
    move(velocity * delta)

    if (is_colliding()):
        if (get_collider() != null):
            if (get_collider() extends player_class):
                get_collider().stamina -= 100
        var a = velocity.angle_to(get_collision_normal())
        velocity = - velocity.rotated(2*a)
        move(velocity * delta)

    velocity = velocity.normalized() * speed

    if (dead):
        queue_free()

func _ready():
    set_fixed_process(true)
